<template>
	<view class="common-container">
		<view class="status_bar"> </view>

		<u-navbar title="我的">
			<view class="u-nav-slot" slot="left">
			</view>
		</u-navbar>
		<view class="main-wrap has-navbar-tabbar">
			<view class="user-info-container">
				<u-avatar :src="$constants.getFileView(userInfo.avatar)" class="user-avatar" size="68"></u-avatar>
				<text class="user-info">{{userInfo.realName}}</text>
			</view>
			<view class="function-container">
				<u-cell-group class="card-container" :border="false">
					<u-cell title="用户名" :value="userInfo.username" :border="false"></u-cell>
					<u-cell title="隶属部门" :value="userInfo.cacheOrganizationVo.name" :border="false"></u-cell>
					<u-cell title="手机号" :value="userInfo.mobile" :border="false"></u-cell>
				</u-cell-group>


				<view class="uni-btn-v">
					<u-button @click="handleLogout" type="error">退出当前账号</u-button>
				</view>
			</view>


		</view>
		<u-modal :show="logoutShow" @confirm="doLogout" title="系统提示" content='是否真的退出当前账号,是否继续?' :showCancelButton="true"
			@cancel="logoutCancel"></u-modal>

	</view>
</template>

<script>
	export default {
		data() {
			return {
				userInfo: {},
				logoutShow: false
			}
		},
		onLoad() {

		},
		created() {
			this.userInfo = uni.getStorageSync(this.$constants.USER_INFO)
		},
		methods: {
			handleLogout() {
				this.logoutShow = true;
			},
			logoutCancel() {
				this.logoutShow = false
			},
			doLogout() {
				this.$store.dispatch('logout')
			}
		}
	}
</script>

<style lang="scss" scoped>
	.user-info-container {
		background-color: #fff;
		display: flex;
		flex-direction: row;
		height: 100px;
		align-items: center;
		padding: 0 20px;

		.user-info {
			margin-left: 20px;
			font-weight: 700;
			font-size: 18px;
		}
	}

	.function-container {
		padding: 0 var(--page-padding);
		margin-top: 15px;
	}
</style>